package com.bdrm.mapper;

import com.bdrm.annotation.AutoFill;
import com.bdrm.dto.DishPageQueryDTO;
import com.bdrm.entity.Dish;
import com.bdrm.enumeration.OperationType;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    Page<Dish> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    @Select("select * from dish where id=#{id}")
    Dish getDishById(Long id);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    @Delete("delete from dish where id = #{id}")
    void deleteById(Long id);

    void deleteByIds(List<Long> ids);

    //查看菜品是否启用
    @Select("select d.* from dish d left join setmeal_dish sd on d.id = sd.dish_id " +
            "where setmeal_id = #{id}")
    List<Dish> getSetmealById(Long id);

    /**
     * 根据分类id查询菜品
     * @param dish
     * @return
     */
    List<Dish> list(Dish dish);
}
